// ===============================================
// app_cupertino_bar
//
// Create by Will on 30/3/2024 20:09
// Copyright Will.All rights reserved.
// ===============================================

import 'package:flutter/cupertino.dart';

const _HeroTag _defaultHeroTag = _HeroTag(null);

@immutable
class _HeroTag {
  const _HeroTag(this.navigator);

  final NavigatorState? navigator;

  // Let the Hero tag be described in tree dumps.
  @override
  String toString() =>
      'Default Hero tag for Cupertino navigation bars with navigator $navigator';

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) {
      return true;
    }
    if (other.runtimeType != runtimeType) {
      return false;
    }
    return other is _HeroTag && other.navigator == navigator;
  }

  @override
  int get hashCode => identityHashCode(navigator);
}

class AppCupertinoBar extends CupertinoNavigationBar {
  const AppCupertinoBar({
    super.key,
    this.leading,
    this.middle,
    this.trailing,
    this.backgroundColor,
    this.brightness,
    this.padding,
    this.border,
    this.transitionBetweenRoutes = false,
    this.heroTag = _defaultHeroTag,
  });

  @override
  final Widget? leading;

  // final bool automaticallyImplyLeading;
  //
  // final bool automaticallyImplyMiddle;

  // final String? previousPageTitle;

  @override
  final Widget? middle;

  @override
  final Widget? trailing;

  @override
  final Color? backgroundColor;

  @override
  final Brightness? brightness;

  @override
  final EdgeInsetsDirectional? padding;

  @override
  final Border? border;

  @override
  final bool transitionBetweenRoutes;

  @override
  final Object heroTag;

  @override
  State<AppCupertinoBar> createState() => _AppCupertinoBarState();
}

class _AppCupertinoBarState extends State<AppCupertinoBar> {
  @override
  Widget build(BuildContext context) {
    return CupertinoNavigationBar(
      heroTag: widget.heroTag,
      transitionBetweenRoutes: widget.transitionBetweenRoutes,
      // border: widget.border ?? AppStyle.appCupertinoNavigationBarBorder,
      leading: widget.leading,
      middle: widget.middle,
      trailing: widget.trailing,
      backgroundColor: widget.backgroundColor,
      brightness: widget.brightness,
      padding: widget.padding,
    );
  }
}
